<?php

namespace app\api\controller;

use app\common\controller\Api;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    /**
     * 系统配置
     *
     * @ApiTitle    (系统配置)
     * @ApiMethod   (GET)
     * @ApiRoute    (/api/index/system)
     * @ApiReturnParams   (name="title", type="string", required=true, description="网站名")
     * @ApiReturnParams   (name="logo1", type="string", required=true, description="LOGO1(小)")
     * @ApiReturnParams   (name="logo2", type="string", required=true, description="LOGO2(大)")
     * @ApiReturnParams   (name="keywords", type="string", required=true, description="网站关键字")
     * @ApiReturnParams   (name="description", type="string", required=true, description="网站描述")
     * @ApiReturnParams   (name="beian", type="string", required=true, description="备案号")
     * @ApiReturnParams   (name="pro_desc", type="text", required=true, description="作品欣赏短介绍")
     * @ApiReturnParams   (name="environment", type="image", required=true, description="公司环境")
     * @ApiReturnParams   (name="app_image", type="image", required=true, description="APP二维码")
     * @ApiReturnParams   (name="qq_image", type="image", required=true, description="QQ二维码")
     * @ApiReturnParams   (name="wb_image", type="image", required=true, description="微博二维码")
     * @ApiReturnParams   (name="wechat_image", type="image", required=true, description="微信二维码")
     * @ApiReturnParams   (name="company_desc", type="text", required=true, description="公司介绍")
     * @ApiReturnParams   (name="email", type="string", required=true, description="邮箱")
     * @ApiReturnParams   (name="mobile", type="string", required=true, description="电话/微信")
     * @ApiReturnParams   (name="address", type="string", required=true, description="地址")
     * @ApiReturnParams   (name="address_lat", type="string", required=true, description="地址经纬度")
     * @ApiReturnParams   (name="address_lng", type="string", required=true, description="地址经纬度")
     * @ApiReturn   ({"code": 200,"msg": "请求成功","time": "1698832116","data": {"id": 1,"title": "明熙灯光","logo1": "http://mingxi.me.com/uploads/20231101/7a56396007930ee518b8147e18dd9b36.png","logo2": "http://mingxi.me.com/uploads/20231101/a9d85ad5f043e7d37e3452df4bc11bdb.png","keywords": "明熙灯光设计专注于个性化私宅、酒店、办公、会所等灯光空间。","description": "明熙灯光设计专注于个性化私宅、酒店、办公、会所等灯光空间。","beian": "浙ICP备2022009352号-1","pro_desc": "明熙灯光设计专注于\r\n个性化私宅、酒店、办公、会所等灯光空间。","environment": "http://mingxi.me.com/uploads/20231101/ad343f383ab850853e66d5f880061022.png","app_image": "http://mingxi.me.com/uploads/20231101/1c0331fdfac316c5cb293b4178abc8ef.png","qq_image": "http://mingxi.me.com/uploads/20231101/1c0331fdfac316c5cb293b4178abc8ef.png","wb_image": "http://mingxi.me.com/uploads/20231101/1c0331fdfac316c5cb293b4178abc8ef.png","wechat_image": "http://mingxi.me.com/uploads/20231101/1c0331fdfac316c5cb293b4178abc8ef.png","company_desc": "明熙灯光设计成立于2018年，专注于灯光美学设计<br /><br />你所能想象的一切场景关于光影，可能都存在我们新奇的灵感，既定无聊的模式需要挑战各种奇妙光影逐渐成真<br /><br />一场蓄谋已久的碰撞迸发出意外惊喜的光芒，没有什么能比热烈的、温柔的、朦胧的光更能诠释对美好生活的渴望，让抽象的空间被感知<br /><br />专业方案团队（DLALUX设计、施工图深化、SU效果展示）邀你一起享受生活享受光影<br /><br />光是点亮艺术灵感的缪斯，塑造出梦幻一般的氛围<br /><br />熟悉的形态因光的渲染而产生意想不到的效果<br /><br />用光的视觉温度营造空间氛围的温度，以达到影响情绪的目的，定格一张张有温度的幸福画面<br /><br />提供室内和室外场所的灯光方案设计及施工、照明设备选型、智能照明控制系统规划施工等服务<br /><br />通过光影营造空间秩序感<br /><br />追求具有美感、舒适度和实用性的光影效果<br />","email": "1310147353@qq.com","mobile": "15167946295","address": "迪荡街道复旦科技园16楼1603室","address_lat": "31.29043","address_lng": "121.49948"
        }
    })
     */
    public function system()
    {
        $system = model('app\admin\model\System')->get(1);
        if(isset($system->logo1)) $system->logo1 = full_url($system->logo1);
        if(isset($system->logo2)) $system->logo2 = full_url($system->logo2);
        if(isset($system->environment)) $system->environment = full_url($system->environment);
        if(isset($system->app_image)) $system->app_image = full_url($system->app_image);
        if(isset($system->qq_image)) $system->qq_image = full_url($system->qq_image);
        if(isset($system->wb_image)) $system->wb_image = full_url($system->wb_image);
        if(isset($system->wechat_image)) $system->wechat_image = full_url($system->wechat_image);

        $this->success('请求成功',$system,200);
    }


    /**
     * banner
     *
     * @ApiTitle    (banner)
     * @ApiMethod   (GET)
     * @ApiRoute    (/api/index/banner)
     * @ApiParams   (name="mold", type="string", required=true, description="位置:index=首页,about=关于我们,contact=联系我们")
     * @ApiReturnParams   (name="title", type="string", required=true, description="标题")
     * @ApiReturnParams   (name="desc", type="text", required=true, description="描述")
     * @ApiReturnParams   (name="image", type="image", required=true, description="图片")
     * @ApiReturn   ({"code": 200,"msg": "请求成功","time": "1698910016","data": [{"title": "邀你一起追光而行 即刻发光","desc": "We invite you to chase the light and shine instantly","image": "http://mingxi.me.com/uploads/20231101/d7199592529edae5271143a076ff1215.png","mold_text": "","status_text": ""}]})
     */
    public function banner()
    {
        $mold = $this->request->request('mold','index');
        $data = model('app\admin\model\Banner')
            ->field(['title','desc','image'])
            ->where(['mold' => $mold,'status' => '1'])
            ->order(['weigh' => 'asc'])
            ->select();
        foreach ($data as $row) {
            $row->image = full_url($row->image);
        }

        $this->success('请求成功',$data,200);
    }


    /**
     * 案例列表
     *
     * @ApiTitle    (案例列表)
     * @ApiMethod   (GET)
     * @ApiRoute    (/api/index/works)
     * @ApiReturnParams   (name="title", type="string", required=true, description="标题")
     * @ApiReturnParams   (name="image", type="image", required=true, description="图片")
     * @ApiReturn   ({"code": 200,"msg": "请求成功","time": "1698889759","data": [{"id": 1,"title": "壹见茶坊","image": "http://mingxi.me.com/uploads/20231101/940838749183f92bdeebbe1760af9039.png"},{"id": 2,"title": "壹见茶坊","image": "http://mingxi.me.com/uploads/20231101/d08ea2d1e5519f7189cb44b95d6a10e7.png"},{"id": 3,"title": "壹见茶坊","image": "http://mingxi.me.com/uploads/20231101/3fae594888b34dc36b59e435ecb83341.png"},{"id": 4,"title": "壹见茶坊","image": "http://mingxi.me.com/uploads/20231101/0c9c45ff5b8552b5ba8a52fc33445913.png"}]
    })
     */
    public function works()
    {
        $data = model('app\admin\model\Works')
            ->field(['id','title','image'])
            ->where(['status' => '1'])
            ->order(['weigh' => 'asc'])
            ->select();
        foreach ($data as $row) {
            $row->image = full_url($row->image);
        }

        $this->success('请求成功',$data,200);
    }


    /**
     * 公司部门
     *
     * @ApiTitle    (公司部门)
     * @ApiMethod   (GET)
     * @ApiRoute    (/api/index/department)
     * @ApiReturn   ({"code": 200,"msg": "请求成功","time": "1698890236","data": [{"id": 1,"title": "设计部","department": [{"id": 1,"cat_id": 1,"title": "明熙灯光设计专注于个性化私宅、酒店、办公、会所等灯光空间。","image": "http://mingxi.me.com/uploads/20231101/763fb215a85b9aa18c0dc86ccb97edf8.png"}]},{"id": 2,"title": "市场部","department": [{"id": 2,"cat_id": 2,"title": "明熙灯光设计专注于个性化私宅、酒店、办公、会所等灯光空间。","image": "http://mingxi.me.com/uploads/20231101/aefe68a309ca6b4339eebb6884598bb2.png"}]}]})
     */
    public function department()
    {
        $data = model('app\admin\model\department\Cat')
            ->with(['department' => function($q) {
                $q->field('id,cat_id,title,image');
                $q->where('status','1');
            }])
            ->field(['id','title'])
            ->where(['status' => '1'])
            ->order(['weigh' => 'asc'])
            ->select();
        foreach ($data as $row) {
            if($row->department){
                foreach ($row->department as $department) {
                    $department->image = full_url($department->image);
                }
            }
        }

        $this->success('请求成功',$data,200);
    }



    /**
     * 合作伙伴
     *
     * @ApiTitle    (合作伙伴)
     * @ApiMethod   (GET)
     * @ApiRoute    (/api/index/partner)
     * @ApiReturnParams   (name="title", type="string", required=true, description="标题")
     * @ApiReturnParams   (name="image", type="image", required=true, description="图片")
     * @ApiReturn   ({"code": 200,"msg": "请求成功","time": "1698890829","data": [{"id": 1,"title": "Schneider","image": "http://mingxi.me.com/uploads/20231101/a384c31d3fd63722d81b4793fbd367b2.png"},{"id": 2,"title": "PHILIPS","image": "http://mingxi.me.com/uploads/20231101/1a9997c54eb1de77e7e2ccd836d20a8b.png"},{"id": 3,"title": "Haier","image": "http://mingxi.me.com/uploads/20231101/a92fdbb3297006770aac43be63d1070a.png"},{"id": 4,"title": "永芝","image": "http://mingxi.me.com/uploads/20231101/b1b30df5e15ef4b2fc96d67a15130553.png"},{"id": 5,"title": "ABB","image": "http://mingxi.me.com/uploads/20231101/e25b74bc2e4e4ce7e57bc8a474566207.png"},{"id": 6,"title": "美的","image": "http://mingxi.me.com/uploads/20231101/3373ab21c21b2d04276d9dab888dc4e4.png"},{"id": 7,"title": "正泰","image": "http://mingxi.me.com/uploads/20231101/27f449015a22b88627360e87edca4095.png"},{"id": 8,"title": "新希望","image": "http://mingxi.me.com/uploads/20231101/86ca6d81bd03dcac2085f356a57eeb18.png"},{"id": 9,"title": "alexa","image": "http://mingxi.me.com/uploads/20231101/0e3612d3fe44dccbeb014c312fcfe7eb.png"},{"id": 10,"title": "Google Assistant","image": "http://mingxi.me.com/uploads/20231101/f7a296551fb732aab0f4dfc769bce761.png"},{"id": 11,"title": "Apple Home","image": "http://mingxi.me.com/uploads/20231101/af7203e1ed141b6669bd1cbf2193f65a.png"},{"id": 12,"title": "Works with SmartThings","image": "http://mingxi.me.com/uploads/20231101/53ecdfefe2c7edfe4cdf75b987d2f998.png"},{"id": 13,"title": "天猫精灵","image": "http://mingxi.me.com/uploads/20231101/693310a406cc91cd604bffdc1b1455a5.png"},{"id": 14,"title": "小度","image": "http://mingxi.me.com/uploads/20231101/1670506595403916af263fbbde933d34.png"},{"id": 15,"title": "SIEMENS","image": "http://mingxi.me.com/uploads/20231101/3df7e058e2354c1991cb953075048630.png"}]})
     */
    public function partner()
    {
        $data = model('app\admin\model\Partner')
            ->field(['id','title','image'])
            ->where(['status' => '1'])
            ->order(['weigh' => 'asc'])
            ->select();
        foreach ($data as $row) {
            $row->image = full_url($row->image);
        }

        $this->success('请求成功',$data,200);
    }


}
